﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Craw
{
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Trim().Length <= 0)
            {
                MessageBox.Show("入口URL不能为空", "提示", MessageBoxButtons.OK);
                return;
            }
            if (this.comboBox1.Text.Length <= 0)
            {
                MessageBox.Show("请选择最大页面数", "提示", MessageBoxButtons.OK);
                return;
            }


            if (this.textBox2.Text.Trim().Length <= 0)
            {
                MessageBox.Show("请输入任务名称", "提示", MessageBoxButtons.OK);
                return;
            }


            JobDTO val = new JobDTO();
            val.Name = this.textBox2.Text.Trim();
            val.Url = this.textBox1.Text.Trim();
            val.LimitPage = Int32.Parse(this.comboBox1.Text);
            val.Status = JobDTO.JOBSTATUS.READY;

            ((FormMain)(this.ParentForm)).addListViewItem(val);

            foreach (Control col in this.Controls)
            {
                if (col is Label | col is Button) continue;

                col.Text = "";
                if (col is ComboBox) {
                    ((ComboBox)col).SelectedIndex = -1;
                }
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            
        }
    }
}
